package org.k.client.controllor;

import com.weibo.api.motan.config.springsupport.annotation.MotanReferer;
import org.k.dto.Result;
import org.k.api.IUserService;
import org.k.dto.UserInfoDto;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by hengxianwang on 16-11-27.
 */

@Controller
@RequestMapping("/users")
public class UserControllor {

    @MotanReferer
    private IUserService userService;

    @ResponseBody
    @RequestMapping(value = "/user/{id}",method = RequestMethod.GET)
    public UserInfoDto findUserById(@PathVariable String id){
        UserInfoDto userInfoDto = userService.findUserById(id);
        return userInfoDto;
    }


    @RequestMapping(value = "/user")
    public Result update(@RequestParam("id") String id, @RequestParam("userName") String userName){
        UserInfoDto userInfoDto = new UserInfoDto();
        userInfoDto.setId(id);
        userInfoDto.setUserName(userName);
        return userService.update(userInfoDto);
    }

}
